package com.kevin.utility.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @author RandomLJ
 * mysql按时间分组格式
 *
 */
public enum MysqlIntervalFormat {
	/**
     * 按日分组
     */
    DAY("%m-%d"),
    
    /**
     * 按周分组
     */
    WEEK("%Y-第%u周"),
    
    /**
     * 按月分组
     */
    MONTH("%m月");
    
    private String mysqlFormat;
    
    MysqlIntervalFormat(String formatString) {
        this.mysqlFormat = formatString;
    }
    
    public String getMysqlFormat() {
        return this.mysqlFormat;
    }
    
    private static final Map<String, MysqlIntervalFormat> stringToEnum = new HashMap<String, MysqlIntervalFormat>();
    static {
        for(MysqlIntervalFormat code : values()) {
            stringToEnum.put(code.toString(), code);
        }
    }
    
    public static MysqlIntervalFormat fromFormat(String symbol) {
        return stringToEnum.get(symbol);
    }
}
